<?php
defined('BASEPATH') OR exit('No direct script access allowed');
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Control-type:application/json;charset='utf-8'");

class Other extends WxHomeController {

	function __construct() {
		parent::__construct();
        $this -> load -> model("Folder_model");
        $this -> load -> library("ProjectService/table_service");
        $this -> load -> library("ProjectService/admin_service");
        $this->load->model('Table1_model');
        $this->load->model('Table2_model');
        $this->load->model('Table3_model');
        $this->load->model('Table4_model');
        $this->load->model('Table5_model');
        $this->load->model('Table5_student_model');
        $this->load->model('Table6_model');
        $this->load->model('Other_statistics_model');
        $this->load->model("Admin_model");
	}

	function Index() {
		$this->load->view('home/other_material_submit');
	}

    function submit1(){
        $this->load->view('home/other_material_submit1');
    }
    function submit2(){
        $this->load->view('home/other_material_submit2');
    }
    function submit3(){
        $this->load->view('home/other_material_submit3');
    }
    function submit4(){
        $this->load->view('home/other_material_submit4');
    }
    function submit5(){
        $this->load->view('home/other_material_submit5');
    }

    function IndexAdd() {
		$this->load->view('home/other_material_submit_add');
	}
    function submit1Add(){
        $this->load->view('home/other_material_submit1_add');
    }
    function submit2Add(){
        $this->load->view('home/other_material_submit2_add');
    }
    function submit3Add(){
        $this->load->view('home/other_material_submit3_add');
    }
    function submit4Add(){
        $this->load->view('home/other_material_submit4_add');
    }
    function submit5Add(){
        $this->load->view('home/other_material_submit5_add');
    }


    
   // 根据type获取所有文件信息
    function getDocument(){
        $type = $_POST['type'];$params = $_POST;
        $document=$this->table_service->getDocumentList($type,$params,true);
        echo json_encode(array('status'=>true,'msg'=>'文件','res'=>$document));exit;
    }


    function tableEdit1(){
        $id=$_POST['id'];
        $folder_id=false;
        $connar['where']=$this->sqlEscape('db_table1.id=??',array($id));
        $connar['join']=array('db_admin','db_admin.id=db_table1.admin_id');
        $connar['items']="db_table1.*,db_admin.usercode,db_admin.username,ifnull(from_unixtime(db_table1.sub_time, '%Y-%m-%d'), '未设置') sub_time";
        $data['detail']=$this->Table1_model->get_single_full($connar);
        if(!empty( $data['detail']['img'])){
            $data['detail']['img'] = explode(',',$data['detail']['img']);
        }else{
            $data['detail']['img'] = [];
        }
        //$data['folder_id']=$folder_id;
        echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   
    }

    function tableSave1(){

        $table1 = copyArray($_POST,array('id','name',"title","content","advice","sub_time",'AttendType'));
        $table1['sub_time']=strtotime($table1['sub_time']);

        if($table1['AttendType'] == '-1'){
            exit(retJson('请选择督导身份',false));
        }

        //自增字段
        $table1['admin_id']= $_SESSION[SESS_USER_HOME]['id'];
        $table1['folder_id']= 0;
        $table1['status']=CommonStatus::UnDeleted[XPHEnum::Value];


        if(isset($_POST['img'])){
			$img=$this->NOTXSS_POST['img'];
			$table1['img']= "";
			for ($i=0;$i<=count($img)-1;$i++){
				$item = $img[$i];
				if (checkStringIsBase64($item)) {
					$checkRet = uploadImg($item, 'SupervisionOther_img');
					if (!$checkRet['status']) {
						exit(toRetJson($checkRet));
					}
					$data=$checkRet["v"];
					
				} else {
					exit(retJson('上传的图片格式不正确！', false));
				}
				if($i == 0){
                    $table1['img'] =$data;
                }else{
                    $table1['img'] .= ','.$data;

                }
			}
		}


        if(!isset($_POST['id']) || $_POST['id'] == ""){
            $table1['created']=time();

            $id=$this -> Table1_model -> add($table1);
            $document=$this->table_service->getDocumentByIdAndType($id,OtherTableType::Table1[XPHEnum::Value]);

            // 其他材料统计
			$this->otherStatistics($table1['admin_id'], 'specialResearch');

            // $folder_img=$this->table_service->getFolderImg($id,OtherTableType::Table1[XPHEnum::Value]);
            // $folder_document=$this->table_service->getDocumentByFolderId($document['folder_id']);
            // if(count($folder_document)>0){
            //  $this->Folder_model->update(array('id'=>$document['folder_id'],'is_have'=>CommonWhether::Whether[XPHEnum::Value]));
            // }
            // $remark=array(
            //  'is_add'=>true,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("添加成功.", true,$document,$remark));
            echo json_encode(array('status'=>true,'msg'=>'添加成功','res'=>$document));exit;
          //  exit(retJson("添加成功.", true,$document));
        }else{  
            //unset($table1['name']);
            $table1['updated']=time();
            $this -> Table1_model -> update($table1);
            $document=$this->table_service->getDocumentByIdAndType($table1['id'],OtherTableType::Table1[XPHEnum::Value]);
            // $folder_img=$this->table_service->getFolderImg($table1['id'],OtherTableType::Table1[XPHEnum::Value]);
            // $remark=array(
            //  'is_add'=>false,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("修改成功.", true,$document,$remark));
           // exit(retJson("修改成功.", true,$document));
              echo json_encode(array('status'=>true,'msg'=>'修改成功','res'=>$document));exit;
        }
    }

    function tableEdit2(){
        $id=$_POST['id'];
        $folder_id=false;
        $connar['where']=$this->sqlEscape('db_table2.id=??',array($id));
        $connar['join']=array('db_admin','db_admin.id=db_table2.admin_id');
        $connar['items']="db_table2.*,db_admin.usercode,db_admin.username,ifnull(from_unixtime(db_table2.sub_time, '%Y-%m-%d'), '未设置') sub_time";
        $data['detail']=$this->Table2_model->get_single_full($connar);
        if(!empty( $data['detail']['img'])){
            $data['detail']['img'] = explode(',',$data['detail']['img']);
        }else{
            $data['detail']['img'] = [];
        }

      //  $data['folder_id']=$folder_id;

       echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   
    }

    function tableSave2(){
        $table2 = copyArray($_POST,array('id','name',"address","type","sub_time",'content','advice','AttendType'));
        $table2['sub_time']=strtotime($table2['sub_time']);

        if($table2['AttendType'] == '-1'){
            exit(retJson('请选择督导身份',false));
        }

        //自增字段
        $table2['admin_id']= $_SESSION[SESS_USER_HOME]['id'];
        $table2['folder_id']= 0;
        $table2['status']=CommonStatus::UnDeleted[XPHEnum::Value];
        if(isset($_POST['img'])){
			$img=$this->NOTXSS_POST['img'];
			$table2['img']= "";
			for ($i=0;$i<=count($img)-1;$i++){
				$item = $img[$i];
				if (checkStringIsBase64($item)) {
					$checkRet = uploadImg($item, 'SupervisionOther_img');
					if (!$checkRet['status']) {
						exit(toRetJson($checkRet));
					}
					$data=$checkRet["v"];
					
				} else {
					exit(retJson('上传的图片格式不正确！', false));
				}
				if($i == 0){
                    $table2['img'] =$data;
                }else{
                    $table2['img'] .= ','.$data;

                }
			}
		}


        if(!isset($_POST['id']) || $_POST['id'] == ""){
            $table2['created']=time();
            $id=$this -> Table2_model -> add($table2);
            $document=$this->table_service->getDocumentByIdAndType($id,OtherTableType::Table2[XPHEnum::Value]);

            // 其他材料统计
			$this->otherStatistics($table2['admin_id'], 'patrol');

            // $folder_img=$this->table_service->getFolderImg($id,OtherTableType::Table2[XPHEnum::Value]);
            // $folder_document=$this->table_service->getDocumentByFolderId($document['folder_id']);
            // if(count($folder_document)>0){
            //  $this->Folder_model->update(array('id'=>$document['folder_id'],'is_have'=>CommonWhether::Whether[XPHEnum::Value]));
            // }
            // $remark=array(
            //  'is_add'=>true,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("添加成功.", true,$document,$remark));
            echo json_encode(array('status'=>true,'msg'=>'添加成功','res'=>$document));exit;
        }else{  
          //  unset($table2['name']);
            $table2['updated']=time();
            $this -> Table2_model -> update($table2);
            $document=$this->table_service->getDocumentByIdAndType($table2['id'],OtherTableType::Table2[XPHEnum::Value]);
            // $folder_img=$this->table_service->getFolderImg($table2['id'],OtherTableType::Table2[XPHEnum::Value]);
            // $remark=array(
            //  'is_add'=>false,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("修改成功.", true,$document,$remark));
            echo json_encode(array('status'=>true,'msg'=>'修改成功','res'=>$document));exit;
        }
    }

    function tableEdit3(){
         $id=$_POST['id'];
        $folder_id=false;
        $connar['where']=$this->sqlEscape('db_table3.id=??',array($id));
        $connar['join']=array('db_admin','db_admin.id=db_table3.admin_id');
        $connar['items']="db_table3.*,db_admin.usercode,db_admin.username,ifnull(from_unixtime(db_table3.sub_time, '%Y-%m-%d'), '未设置') sub_time";
        $data['detail']=$this->Table3_model->get_single_full($connar);
        if(!empty( $data['detail']['img'])){
            $data['detail']['img'] = explode(',',$data['detail']['img']);
        }else{
            $data['detail']['img'] = [];
        }

       // $data['folder_id']=$folder_id;
        echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   
    }

    function tableSave3(){
        $table3 = copyArray($_POST,array('id','name',"address","content","advice","sub_time",'AttendType'));
        $table3['sub_time']=strtotime($table3['sub_time']);

        if($table3['AttendType'] == '-1'){
            exit(retJson('请选择督导身份',false));
        }

        //自增字段
        $table3['admin_id']= $_SESSION[SESS_USER_HOME]['id'];
        $table3['folder_id']= 0;
        $table3['status']=CommonStatus::UnDeleted[XPHEnum::Value];
        if(isset($_POST['img'])){
			$img=$this->NOTXSS_POST['img'];
			$table3['img']= "";
			for ($i=0;$i<=count($img)-1;$i++){
				$item = $img[$i];
				if (checkStringIsBase64($item)) {
					$checkRet = uploadImg($item, 'SupervisionOther_img');
					if (!$checkRet['status']) {
						exit(toRetJson($checkRet));
					}
					$data=$checkRet["v"];
					
				} else {
					exit(retJson('上传的图片格式不正确！', false));
				}
				if($i == 0){
                    $table3['img'] =$data;
                }else{
                    $table3['img'] .= ','.$data;

                }
			}
		}
        if(!isset($_POST['id']) || $_POST['id'] == ""){
            $table3['created']=time();
            $id=$this -> Table3_model -> add($table3);
            $document=$this->table_service->getDocumentByIdAndType($id,OtherTableType::Table3[XPHEnum::Value]);

            // 其他材料统计
			$this->otherStatistics($table3['admin_id'], 'tourInformant');

            // $folder_img=$this->table_service->getFolderImg($id,OtherTableType::Table3[XPHEnum::Value]);
            // $folder_document=$this->table_service->getDocumentByFolderId($document['folder_id']);
            // if(count($folder_document)>0){
            //  $this->Folder_model->update(array('id'=>$document['folder_id'],'is_have'=>CommonWhether::Whether[XPHEnum::Value]));
            // }
            // $remark=array(
            //  'is_add'=>true,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("添加成功.", true,$document,$remark));
            echo json_encode(array('status'=>true,'msg'=>'添加成功','res'=>$document));exit;
        }else{  
          //  unset($table3['name']);
            $table3['updated']=time();
            $this -> Table3_model -> update($table3);
            $document=$this->table_service->getDocumentByIdAndType($table3['id'],OtherTableType::Table3[XPHEnum::Value]);
            // $folder_img=$this->table_service->getFolderImg($table3['id'],OtherTableType::Table3[XPHEnum::Value]);
            // $remark=array(
            //  'is_add'=>false,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("修改成功.", true,$document,$remark));
            echo json_encode(array('status'=>true,'msg'=>'修改成功','res'=>$document));exit;
        }
    }

    function tableEdit4(){
          $id=$_POST['id'];
        $folder_id=false;
        $connar['cond']=array('db_table4.id'=>$id);
        $connar['join'][0]=array('admin a1','a1.id=db_table4.admin_id');  
        $connar['join'][1]=array('admin a2','a2.id=db_table4.teacher_id');         
        $connar['items']=" db_table4.*,a1.username admin_username,a1.usercode admin_usercode,a2.dept_name,a2.username teacher_username,a2.usercode teacher_usercode,ifnull(from_unixtime(db_table4.sub_time, '%Y-%m-%d'), '未设置') sub_time";
        $data['detail']=$this->Table4_model->get_single_full($connar);
        if(!empty( $data['detail']['img'])){
            $data['detail']['img'] = explode(',',$data['detail']['img']);
        }else{
            $data['detail']['img'] = [];
        }
        // $data['folder_id']=$folder_id;
     

         echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   
    }

    function tableTeacher(){
        $teacher_name = $_POST['teacher_name'];
        $arr = array();
        $list  =$this->admin_service->getAllAdmin(false,false,$teacher_name);     
        foreach ($list as $key => $value) {
            $arr[$key]['id'] = $value['id'];
              $arr[$key]['usercode'] = $value['usercode'];
                $arr[$key]['username'] = $value['username'];
        }
         $data['teacher'] = $arr;
         echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   

    }

    function tableSave4(){
        $table4 = copyArray($_POST,array('id','name',"title",'address','teacher_id','teacher_dept_name',"student_status","teacher_status","other_content","advice","sub_time",'AttendType'));
        if($table4['teacher_id']==0){
            exit(retJson("请选择授课教师.", false));
        }

        if($table4['AttendType'] == '-1'){
            exit(retJson('请选择督导身份',false));
        }

        $table4['sub_time']=strtotime($table4['sub_time']);

        //自增字段
        $table4['admin_id']= $_SESSION[SESS_USER_HOME]['id'];
        $table4['folder_id']= 0;
        $table4['status']=CommonStatus::UnDeleted[XPHEnum::Value];
        if(isset($_POST['img'])){
			$img=$this->NOTXSS_POST['img'];
			$table4['img']= "";
			for ($i=0;$i<=count($img)-1;$i++){
				$item = $img[$i];
				if (checkStringIsBase64($item)) {
					$checkRet = uploadImg($item, 'SupervisionOther_img');
					if (!$checkRet['status']) {
						exit(toRetJson($checkRet));
					}
					$data=$checkRet["v"];
					
				} else {
					exit(retJson('上传的图片格式不正确！', false));
				}
				if($i == 0){
                    $table4['img'] =$data;
                }else{
                    $table4['img'] .= ','.$data;

                }
			}
		}
        if(!isset($_POST['id']) || $_POST['id'] == ""){
            $table4['created']=time();
            $id=$this -> Table4_model -> add($table4);
            $document=$this->table_service->getDocumentByIdAndType($id,OtherTableType::Table4[XPHEnum::Value]);

            // 其他材料统计
			$this->otherStatistics($table4['admin_id'], 'specialInspection');

            // $folder_img=$this->table_service->getFolderImg($id,OtherTableType::Table4[XPHEnum::Value]);
            // $folder_document=$this->table_service->getDocumentByFolderId($document['folder_id']);
            // if(count($folder_document)>0){
            //  $this->Folder_model->update(array('id'=>$document['folder_id'],'is_have'=>CommonWhether::Whether[XPHEnum::Value]));
            // }
            // $remark=array(
            //  'is_add'=>true,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("添加成功.", true,$document,$remark));
             echo json_encode(array('status'=>true,'msg'=>'添加成功','res'=>$document));exit;
        }else{  
            //unset($table4['name']);
            $table4['updated']=time();
            $this -> Table4_model -> update($table4);
            $document=$this->table_service->getDocumentByIdAndType($table4['id'],OtherTableType::Table4[XPHEnum::Value]);
            // $folder_img=$this->table_service->getFolderImg($table4['id'],OtherTableType::Table4[XPHEnum::Value]);
            // $remark=array(
            //  'is_add'=>false,
            //  'folder_img'=>$folder_img
            //  );
            // exit(retJson("修改成功.", true,$document,$remark));
            echo json_encode(array('status'=>true,'msg'=>'修改成功','res'=>$document));exit;
        }
    }


    function tableEdit5(){
         $id=$_POST['id'];
        $folder_id=false;

        $data['self']=$this->admin_service->getAdminById(getSess()['id']);
        $connar['where']=$this->sqlEscape('db_table5.id=??',array($id));
        $connar['join']=array('db_admin','db_admin.id=db_table5.admin_id');
        $connar['items']="db_table5.*,db_admin.usercode,db_admin.username,ifnull(from_unixtime(db_table5.sub_time, '%Y-%m-%d'), '未设置') sub_time,ifnull(from_unixtime(db_table5.task_time, '%Y-%m-%d'), '未设置') task_time,ifnull(from_unixtime(db_table5.mentor_time, '%Y-%m-%d'), '未设置') mentor_time";
        $data['detail']=$this->Table5_model->get_single_full($connar);
        if(!empty( $data['detail']['img'])){
            $data['detail']['img'] = explode(',',$data['detail']['img']);
        }else{
            $data['detail']['img'] = [];
        }

        $data['student']=$this->table_service->getTable5Student($id);

        // $data['folder_id']=$folder_id;
        // $data['officer']=$this->admin_service->getAdminByRoleArray(array(WebRole::StudentInfoOfficer[XPHEnum::Value],WebRole::UnitStudentInfoOfficer[XPHEnum::Value]));
        echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   
    }


    function savetable5Img(){
        $imgPath= "";
        if(isset($_POST['img'])){
			$img=$this->NOTXSS_POST['img'];
			for ($i=0;$i<=count($img)-1;$i++){
				$item = $img[$i];
				if (checkStringIsBase64($item)) {
					$checkRet = uploadImg($item, 'SupervisionOther_img');
					if (!$checkRet['status']) {
						exit(toRetJson($checkRet));
					}
					$data=$checkRet["v"];
					
				} else {
					exit(retJson('上传的图片格式不正确！', false));
				}
				if($i == 0){
                    $imgPath =$data;
                }else{
                    $imgPath .= ','.$data;

                }
			}
		}

        echo json_encode(array('status'=>true,'msg'=>'上传成功','res'=>$imgPath));exit;
    }


    function tableSave5(){


        $table5 = copyArray($_POST,array('id','name',"teacher_dept_name",'sub_time','unit_name','unit_address',"unit_contact","unit_phone","task","leader_name","task_time",'eval1','eval1_remark','eval2','eval2_remark','eval3','eval3_remark','eval4','eval4_remark','eval5','eval5_remark','eval6','eval6_remark','eval7','eval7_remark','advice','mentor_name','mentor_phone','mentor_time','summary','AttendType','img'));

        if($table5['AttendType'] == '-1'){
            exit(retJson('请选择督导身份',false));
        }

        $table5['sub_time']=strtotime($table5['sub_time']);
        $table5['task_time']=strtotime($table5['task_time']);
        $table5['mentor_time']=strtotime($table5['mentor_time']);
        //自增字段
        $table5['admin_id']= $_SESSION[SESS_USER_HOME]['id'];
        $table5['folder_id']= 0;
        $table5['status']=CommonStatus::UnDeleted[XPHEnum::Value];
        if(!isset($_POST['id']) || $_POST['id'] == ""){
            $table5['created']=time();
            $id=$this -> Table5_model -> add($table5);
            $document=$this->table_service->getDocumentByIdAndType($id,OtherTableType::Table5[XPHEnum::Value]);

            // 其他材料统计
			$this->otherStatistics($table5['admin_id'], 'postPractice');

            // $folder_img=$this->table_service->getFolderImg($id,OtherTableType::Table5[XPHEnum::Value]);
            // $folder_document=$this->table_service->getDocumentByFolderId($document['folder_id']);
            // if(count($folder_document)>0){
            //  $this->Folder_model->update(array('id'=>$document['folder_id'],'is_have'=>CommonWhether::Whether[XPHEnum::Value]));
            // }
            // $remark=array(
            //  'is_add'=>true,
            //  'folder_img'=>$folder_img
            //  );

            //与其他表不同，增加子表学生信息
            if(isset($_POST['student_class_name'])){
                // $_POST['student_class_name'] = explode(",", $_POST['student_class_name']);
                // $_POST['student_name'] = explode(",", $_POST['student_name']);
                // $_POST['contact_phone'] = explode(",", $_POST['contact_phone']);
                $default_sql=$sql=" insert into db_table5_student (table5_id,student_class_name,student_name,contact_phone) values ";
                foreach ($_POST['student_class_name'] as $k => $v) {
                    if($sql!=$default_sql){
                        $sql.=" , ";
                    }
                    $sql.=$this->sqlEscape(" (??,??,??,??) ",array($id,$v,$_POST['student_name'][$k],$_POST['contact_phone'][$k]));
                }
                if($sql!=$default_sql){
                    $this->Table5_student_model->query($sql,false);
                }
            }

            // exit(retJson("添加成功.", true,$document,$remark));
         echo json_encode(array('status'=>true,'msg'=>'添加成功','res'=>$document));exit;
        }else{  
           // unset($table5['name']);
            $table5['updated']=time();
            $this -> Table5_model -> update($table5);
            $document=$this->table_service->getDocumentByIdAndType($table5['id'],OtherTableType::Table5[XPHEnum::Value]);
            // $folder_img=$this->table_service->getFolderImg($table5['id'],OtherTableType::Table5[XPHEnum::Value]);
            // $remark=array(
            //  'is_add'=>false,
            //  'folder_img'=>$folder_img
            //  );

            //与其他表不同，增加子表学生信息
            $this->Table5_student_model->delBatch($this->sqlEscape(" table5_id=?? ",array($table5['id'])));
            if(isset($_POST['student_class_name'])){
                  // $_POST['student_class_name'] = explode(",", $_POST['student_class_name']);
                  // $_POST['student_name'] = explode(",", $_POST['student_name']);
                  // $_POST['contact_phone'] = explode(",", $_POST['contact_phone']);
                $default_sql=$sql=" insert into db_table5_student (table5_id,student_class_name,student_name,contact_phone) values ";
                foreach ($_POST['student_class_name'] as $k => $v) {
                    if($sql!=$default_sql){
                        $sql.=" , ";
                    }
                    $sql.=$this->sqlEscape(" (??,??,??,??) ",array($table5['id'],$v,$_POST['student_name'][$k],$_POST['contact_phone'][$k]));
                }
                if($sql!=$default_sql){
                    $this->Table5_student_model->query($sql,false);
                }
            }

            // exit(retJson("修改成功.", true,$document,$remark));
             echo json_encode(array('status'=>true,'msg'=>'修改成功','res'=>$document));exit;
        }
    }


        function delDocument(){
           $id=$_POST['id'];
           $this->table_service->delDocument($id,$_POST['type']);
        // $folder_img=$this->table_service->getFolderImg($id,$_POST['type']);
        // exit(retJson('文件',true,$folder_img));
        echo json_encode(array('status'=>true,'msg'=>'删除成功'));exit;
    }


    function getAttendType(){
         $data['AttendType']= $this->table_service->getAttendType($_SESSION[SESS_USER_HOME]['id'],false);
         echo json_encode(array('status'=>true,'msg'=>'返回数据','res'=>$data));exit;   
    }


	// 其他材料统计 field:字段名
	private function otherStatistics ($admin_id, $field)
	{
		$other = $this->Other_statistics_model->get_single(array('admin_id' => $admin_id));
		if (empty($other)) {
			$admin = $this->Admin_model->get_single(array('id' => $admin_id));
			$add = array(
				'admin_id'  => $admin_id,
				'username'  => $admin['username'],
				'dept_name' => $admin['dept_name'],
				$field      => 1,
			);
			$this->Other_statistics_model->add($add);
		} else {
			$update['id'] = $other['id'];
			$update[$field] = $other[$field]+1;
			$this->Other_statistics_model->update($update);
		}
	}
}
